package com.kx.game.center.common;

import com.kx.game.center.common.enums.IndexedEnum;
import com.kx.game.center.utils.EnumUtil;

import java.util.List;

public enum ServerEnum implements IndexedEnum {
    START(1, "服务器启动"),
    STOP(2, "服务器停止"),
    STOPERROR(3, "服务器异常停止"),

    GAMER(4, "游戏服"),
    MAIL(5, "邮件服"),
    FRIEND(6, "好友服");

    private final int index;

    private String param;

    ServerEnum(int index, String param) {
        this.index = index;
        this.param = param;
    }

    /**
     * 按索引顺序存放的枚举数组
     */
    private static final List<ServerEnum> indexes = IndexedEnumUtil
            .toIndexes(ServerEnum.values());

    public static ServerEnum indexOf(final int index) {
        return EnumUtil.valueOf(indexes, index);
    }

    public static ServerEnum getMaxPlatformType() {
        for (int i = indexes.size() - 1; i > 0; i--) {
            if (indexes.get(i) != null)
                return indexes.get(i);
        }
        return null;
    }

    @Override
    public int getIndex() {
        return index;
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public static List<ServerEnum> getIndexes() {
        return indexes;
    }
}
